<template>
	<view class="custom-radio-group">
		<view class="custom-radio-item" v-for="item in options" :key="item.value" @click="selectItem(item.value)"
			:class="{'active': selectedValue === item.value}">
			<view class="radio-circle">
				<text class="radio-text">{{item.label}}</text>
				<view class="radio-dot" v-if="selectedValue === item.value">
					<image class="icon" mode="widthFix" :src="imageUrl +'list/check.png'"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			options: {
				type: Array,
				default: () => []
			},
			value: {
				type: [String, Number],
				default: ''
			}
		},
		data() {
			return {
				selectedValue: this.value
			}
		},
		watch: {
			value(newVal) {
				this.selectedValue = newVal
			}
		},
		methods: {
			selectItem(value) {
				this.selectedValue = value
				this.$emit('input', value)
				this.$emit('change', value)
			}
		}
	}
</script>

<style scoped>
	.custom-radio-group {
		overflow: hidden;
		margin: 0 -10rpx;
	}

	.custom-radio-item {
		float: left;
		width: 50%;
		margin-bottom: 20rpx;
	}

	.radio-circle {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0 10rpx;
		background-color: #F6F6F6;
		height: 88rpx;
		font-size: 28rpx;
		border: 1px solid transparent;
		transition: .3s;
		border-radius: 8rpx;
	}

	.active .radio-circle {
		border-color: #24A7CE;
		background-color: rgba(36, 167, 206, 0.1);
	}

	.radio-dot {
		width: 32rpx;
		height: 24rpx;
		position: absolute;
		right: 0;
		bottom: 0;
	}

	.radio-dot .icon {
		display: block;
		width: 100%;
		height: 100%;
	}

</style>